<?php

/* 
 * planning/show-resume.phtml
 */
use RHX\Helper\RHDateTime;
use RHX\Helper\Number;
?>
<?php
// variables
$stats = $this->stats;
$codes = $stats['codes'];
$heures	= $stats['heures'];
$week = $stats['week'];
$employe= $this->employe;
$codec = $this->codec;
$planning = $this->planning;
$dayName = array('lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche');
?>
<div class="content-body">
    <h4>Résumé de la semaine pour le matricule <b><?php echo '#' .$employe->matricule .' ' .$employe->prenom .' ' .$employe->nom1 ?></b></h4>
    Horaire Hebdomadaire <em><?php echo $employe->getHoraireHebdo(true) .' heure(s)' ?></em>
    <hr>
    <h5>Occurence des codes activités</h5>
    <?php foreach($codes as $code => $value): ?>
    <div class="row">
	<div class='span1 <?php echo $codec[$code]; ?>'><?php echo $codec[$code]; ?></div>
	<div class='span1'><b><?php echo $value; ?></b> fois</div>
	<div class='span2'>Total des heures</div>
	<?php $heure = $heures[$code]; ?>
	<div class='span2'><?php echo $heure->totalHours() .' (<b>' .Number::frenchFormat(RHDateTime::toFloat($heure->totalHours())) .'</b>)' ?></div>
    </div>
    <?php endforeach; ?>
    <hr>
    <h5>Heures détaillées par jour</h5>
    <table class='table table-bordered table-condensed list-table'>
	<thead>
	    <tr>
		<?php foreach($dayName as $day): ?>
		<td><?php echo $day; ?></td>
		<?php endforeach; ?>
		<td>Total</td>
	    </tr>
	</thead>
	<tbody>
	    <tr>
		<?php 
		$total = new RHDateTime(); 
		$total->setTime();
		?>
		<?php foreach($dayName as $day): ?>
		<?php 
		$jour = $week[$day];
		$total->addHours($jour->getDiff(false), false);
		?>
		<td><?php echo $jour->getDiff(false) .' (' .$jour->getDiff(true, true) .')'; ?></td>
		<?php endforeach; ?>
		<td><b><?php echo $total->totalHours() .' (' .Number::frenchFormat(RHDateTime::toFloat($total->totalHours())) .')' ?></b></td>
	    </tr>
	</tbody>
    </table>
    <div class='span4'>
	Heures prévues de la semaine :
    </div>
    <div class="span2">
	<b><?php echo Number::frenchFormat(RHDateTime::toFloat($planning->heure_prevues)) ?></b> heure(s)
    </div>
    <div class='span4'>
	Heures travaillées de la semaine :
    </div>
    <div class="span2">
	<b><?php echo Number::frenchFormat(RHDateTime::toFloat($total->totalHours())) ?></b> heure(s)
    </div>
    <div class='span4'>
	Heures non-planifiées de la semaine :
    </div>
    <div class="span2">
	<?php $nonPrevues = (RHDateTime::toFloat($total->totalHours()) - RHDateTime::toFloat($planning->heure_prevues)); ?>
	<b><?php echo (($nonPrevues > 0) ? '+' : '') .Number::frenchFormat($nonPrevues) ?></b> heure(s)
    </div>
</div>